package com.lu.statistics.entity.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * 业务流程类型，根据业务需求添加
 */
@Getter
@AllArgsConstructor
public enum ProcDefKey {
    P_PUB_EXAMINE("公示审核流程", "P_PUB_EXAMINE"),
    P_ACT_EXAMINE("活动审核流程", "P_ACT_EXAMINE"),
    /**
     * 供需业务 a_s_n_d_info.id
     */
    PURCHASE_BARGAIN("采购生命流程", "PURCHASE_BARGAIN"),

    P_SPE_EXAMINE("专家会员审核流程", "P_SPE_EXAMINE"),
    P_DEAL_EXAMINE("交易会员审核流程", "P_DEAL_EXAMINE"),
    P_ORG_EXAMINE("机构会员审核流程", "P_ORG_EXAMINE"),
    P_PRO_EXAMINE("项目会员审核流程", "P_PRO_EXAMINE"),
    BUYER("意向登记流程","BUYER"),
    ORDER("订单模块","ORDER"),
    MARGIN_BACK("保证金退还","MARGIN_BACK"),
    P_SNAKE_TEST("Snake测试专用","P_SNAKE_TEST");


    /**
     * 描述信息
     */
    private final String description;

    /**
     * 流程定义key
     */
    private final String procDefKey;

    /**
     * 流程定义缓存，key:流程定义key ，value:枚举
     */
    private static Map<String, ProcDefKey> defKeyMap = Arrays.stream(values())
            .collect(Collectors.toMap(ProcDefKey::getProcDefKey, o -> o));


    /**
     * 判断code是否相等
     *
     * @param procDefKey
     * @return
     */
    public boolean codeEquals(String procDefKey) {
        return this.procDefKey.equals(procDefKey);
    }

    /**
     * 获取枚举数据
     *
     * @param procDefKey 定义Key
     */
    public static ProcDefKey getEnum(String procDefKey) {
        return defKeyMap.get(procDefKey);
    }
}
